import service from "../../utils/request"

export const addDict = async (data: Dict): Promise<Result<string>> =>
    await service.post(`/dict`, data)

export const getDictPage = async (page: number, dict_name: string): Promise<PageResult<ListDict[]>> =>
    await service.get(`/dict/page?page=${page}&dict_name=${dict_name}`)

export const editDict = async (id: string, data: Dict): Promise<Result<string>> =>
    await service.patch(`/dict/${id}`, data)

export const delDict = async (id: string): Promise<Result<string>> =>
    await service.delete(`/dict/${id}`)

export const manyDelDict = async (ids: string): Promise<Result<string>> =>
    await service.delete(`/dict/many/${ids}`)

export const addDictItem = async (data: DictItem): Promise<Result<string>> =>
    await service.post(`/dict-item`, data)

export const getDictItemPage = async (page: number, dictId: string): Promise<PageResult<ListDictItem[]>> =>
    await service.get(`/dict-item/page?page=${page}&dictId=${dictId}`)

export const editDictItem = async (id: string, data: DictItem): Promise<Result<string>> =>
    await service.patch(`/dict-item/${id}`, data)

export const delDictItem = async (id: string): Promise<Result<string>> =>
    await service.delete(`/dict-item/${id}`)

export const manyDelDictItem = async (ids: string): Promise<Result<string>> =>
    await service.delete(`/dict-item/many/${ids}`)
